﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Transactions;
using Twitter;
using Twitter.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Configuration;

namespace FriendsNearbyBot.Tests
{
    [TestFixture]
    public class TwitterMessageLoggerFixture
    {

        [Test]
        public void MessageLoggerAddsRecordInDatabase()
        {
            int previousMessageCount = 0;
            using (new TransactionScope())
            {

                TwitterLogDataContext ctx = new TwitterLogDataContext(ConfigurationManager.ConnectionStrings["FriendsNearbyDB"].ConnectionString);
                previousMessageCount = ctx.LogTwitterMessages.Count();

                TwitterMessageLogger.AddLog("test", "test", "", null, "test");

                Assert.AreEqual(previousMessageCount + 1, ctx.LogTwitterMessages.Count());
            }
        }
    }
}
